// Patterns.cpp : implementation file
//

#include "stdafx.h"
#include "SQLInjectionISAPISettings.h"
#include "Patterns.h"


// CPatterns dialog

IMPLEMENT_DYNAMIC(CPatterns, CPropertyPage)

CPatterns::CPatterns(CWnd* pParent /*=NULL*/)
	: CPropertyPage(CPatterns::IDD)
	, onlyPostGet(FALSE)
{

}

BOOL CPatterns::OnInitDialog()
{
	CPropertyPage::OnInitDialog();
	LVCOLUMN header;
	
	CRect dimension;
	listPatterns.GetClientRect( &dimension );
	//dimension = new RECT(0,0, 0, 0);
	const int size = dimension.Width() / 2;

	header.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	header.fmt = LVCFMT_LEFT;
	header.cx = dimension.Width() / 2;
	header.pszText = _T("Input Pattern");
	listPatterns.InsertColumn(0, &header);
	
	header.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	header.fmt = LVCFMT_LEFT;
	header.cx = dimension.Width() - size;
	header.pszText = _T("Safe Pattern");
	listPatterns.InsertColumn(1, &header);

	listPatterns.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);

	AddPair(_T("\\bor\\b"), _T("kjkjk"));
	AddPair(_T("ooo"), _T("kkkkkk"));

	return TRUE;
	

	
}
CPatterns::~CPatterns()
{
}

void CPatterns::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Check(pDX, IDC_POSTANDGET, onlyPostGet);
	DDX_Control(pDX, IDC_INPUTPATTERN, textInput);
	DDX_Control(pDX, IDC_OUTPUTPATTERN, textOutput);
	DDX_Control(pDX, IDC_LISTPATTERN, listPatterns);
}


BEGIN_MESSAGE_MAP(CPatterns, CDialog)
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LISTPATTERN, &CPatterns::OnLvnItemchangedListpattern)
END_MESSAGE_MAP()


// CPatterns message handlers

void CPatterns::OnLvnItemchangedListpattern(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
	// TODO: Add your control notification handler code here
	*pResult = 0;
}

void CPatterns::AddPair(LPWSTR Pattern, LPWSTR Safe)
{
	LVITEM item;

	int i = listPatterns.GetItemCount();
	item.mask = LVIF_TEXT;
	item.iItem = i;
	item.iSubItem = 0;
	item.pszText = Pattern;
	listPatterns.InsertItem(&item);

	item.mask = LVIF_TEXT;
	item.iItem = i;
	item.iSubItem = 1;
	item.pszText = Safe;
	listPatterns.SetItemText(i, 1, Safe);

	
}
